package com.chapter12.try_catch;

import java.util.Scanner;

public class exercise_exception1 {
    public static void main(String[] args) {

        boolean loop = true;
        while (loop) {
            try {
                System.out.println("请输入整数");
                Scanner scanner = new Scanner(System.in); //键盘键入
                int next = Integer.parseInt(scanner.next());
                //这里可以将scanner.next()用字符串变量接收
                /*
                * String str = "";
                * str = scanner.next();
                * int number = Integer.parseInt(str);
                * */
            } catch (Exception e) {
                loop = true;
                continue;
            }
            loop = false;
        }
    }
}
